package com.uxwine.view;

import com.uxwine.alarm.R;
import com.uxwine.view.SlideWindow.OnWindowEventListener;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

public class SlideDialog extends Dialog {
	
	private OnWindowEventListener mOnWindowEventListener;

	public SlideDialog(Context context) {
		super(context, R.style.SlideDialog);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Window win = getWindow();
		WindowManager.LayoutParams params = new WindowManager.LayoutParams();
		
		//这里也很难得的哇
		params.gravity = Gravity.TOP;
		params.width = WindowManager.LayoutParams.MATCH_PARENT;
		win.setAttributes(params);
		
		//非常不容呀，可以算是机密啦
		win.getDecorView().setPadding(0, 0, 0, 0);
		win.setWindowAnimations(R.style.SlideWindow);	
	}
	
	public void exit(int code) {
		dismiss();
		if(null != mOnWindowEventListener)
			mOnWindowEventListener.onExit(code);
	}

	public static interface OnWindowEventListener
	{
		public void onExit(int code);
	}
}
